package org.example.nebula.controller;

import cn.hutool.json.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.nebula.entity.input.SummaryInput;
import org.example.nebula.entity.out.Result;
import org.example.nebula.service.SpaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author: jszhang
 * @date: 2025/10/27-9:07
 */
@Api("空间查询")
@Slf4j
@RestController
@RequestMapping("/space")
public class SpaceController {

    @Autowired
    private SpaceService spaceService;

    @ApiOperation("查询所有的空间")
    @RequestMapping(value = "/getAllSpace", method = RequestMethod.GET)
    public Result<?> getAllSpace() {
        List<String> allSpace = spaceService.getAllSpace();
        return Result.OK(allSpace);
    }

    @ApiOperation("数据库总体信息查看")
    @PostMapping( "/summary")
    public Result<?> primaryFields(@Valid @RequestBody SummaryInput summaryInput) {
        JSONObject jsonObject = spaceService.getSummary(summaryInput);
        return Result.OK(jsonObject);
    }

}
